home *** CD-ROM | disk | FTP | other *** search
- ⁄ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒø
- ≥ FlagTest version 2.0· 27-03-94 Copyright (c) 1994 by Erik de Neve ≥
- ¿ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŸ
-
- This utility tests the behavior of the Intel 80XXX CPU flags for
- particular instructions or instruction sequences.
- A detailed report is written about how the flags were affected by a
- test routine, which is called with a predefined range of input
- numbers. The output can be redirected to a file.
-
- FlagTest will report the state of all nine conditions on which the
- seventeen ( 8*2 + JCXZ ) possible conditional jumps can be based.
- More than seventeen seem to exist, but this is because of
- the large number of multiple names - e.g. JNB (Jump if Not Below)
- is exactly the same instruction as JAE (Jump if Above and Equal)
- and JNC (Jump if No Carry) - see also the summary below.
-
- Nonexisting flag bit numbers are used to indicate conditions
- based on more than one flag, or on the CX register.
- These are identified in the output by using the names of the
- corresponding conditional jumps that test for them:
-
- 32 JCXZ = CX=0 CX register is Zero
- 33 JGE = SF=OF Greater or Equal (signed)
- 34 JG = ZF=0 and SF=OF Greater (signed)
- 35 JA = CF=0 and ZF=0 Above (unsigned)
-
- Flags or conditions are either SET, CLEARED, FLIPPED, UNCHANGED,
- or UNDEFINED.
- Undefined here means that certain conditions are inconclusive, for
- example the "ABOVE" condition means CF=0 and ZF=0 , but when at least
- one of these flags displays any action other than a simple SET or
- CLEAR, FlagTest will label the combined result as undefined.
-
- For some instructions, specific flags are officially branded
- "undefined" by Intel - like the state of the parity, sign and zero
- flags after a MUL instruction.
- This means in most cases they DO get set or cleared - as FlagTest will
- show - but you are warned not to rely on the same results for all
- situations, or on all generations of Intel CPU's and their clones.
-
- The turbo pascal source code can be recompiled to test any assembly
- language instruction for any input range; just change the value of
- Startcount and Endcount, and put the instruction(s) to be analyzed as
- inline assembler in the procedure TestRoutine. The globally defined
- word-sized variable COUNT contains the input.
-
- I originally created FlagTest to help design and debug
- complex combinations of conditional jumps, like:
-
- CMP CX,3
- JCXZ Label0 ; CX = 0
- JA Label4 ; CX = 4+
- JE Label3 ; CX = 3
- JPE Label2 ; CX = 2
- JPO Label1 ; CX = 1
-
- I know this example has limited practical value (the JPO is redundant,
- and alternative zero-checking methods that avoid using JCXZ are faster
- on 386+ processors) but it does illustrate how to squeeze every
- possible bit of information from the flag-states.
-
-
- This code may be distributed as copyrighted "freeware", provided
- it is not modified and the copyright notice remains intact.
-
- Please send your comments via E-mail to:
-
- Erik de Neve Internet: 100121.1070@compuserve.com
- CompuServe: 100121,1070
-
-
-
- APPENDIX - Summary of INTEL 80XXX Conditional Jumps
- ____________________________________________________________________
-
- Instruction Will jump when...
- ____________________________________________________________________
-
- JC Jump if Carry CF=1
- JB Jump if Below CF=1
- JNAE Jump if Not Above or Equal CF=1
-
- JNC Jump if Not Carry CF=0
- JNB Jump if Not Below CF=0
- JAE Jump if Above or Equal CF=0
- ....................................................................
-
- JA Jump if Above CF=0 and ZF=0
- JNBE Jump if Not Below or Equal CF=0 and ZF=0
-
- JNA Jump if Not Above CF=1 or ZF=1
- JBE Jump if Below or Equal CF=1 or ZF=1
- ....................................................................
-
- JCXZ Jump if CX Zero CX=0
- ....................................................................
-
- JO Jump if Overflow (signed) OF=1
-
- JNO Jump if Not Overflow (signed) OF=0
- ....................................................................
-
- JP Jump if Parity PF=1
- JPE Jump if Parity Even PF=1
-
- JNP Jump if No Parity PF=0
- JPO Jump if Parity Odd PF=0
- ....................................................................
-
- JGE Jump if Greater or Equal (signed) SF=OF
- JNL Jump if Not Less (signed) SF=OF
-
- JNGE Jump if Not Greater or Equal (signed) SF <> OF
- JL Jump if Less (signed) SF <> OF
- ....................................................................
-
- JS Jump if Signed (signed) SF=1
-
- JNS Jump if Not Signed (signed) SF=0
- ....................................................................
-
- JE Jump if Equal ZF=1
- JZ Jump if Zero ZF=1
-
- JNE Jump if Not Equal ZF=0
- JNZ Jump if Not Zero ZF=0
- ....................................................................
-
- JG Jump if Greater (signed) ZF=0 and SF=OF
- JNLE Jump if Not Less or Equal (signed) ZF=0 and SF=OF
-
- JNG Jump if Not Greater (signed) ZF=1 or SF <> OF
- JLE Jump if Less or Equal (signed) ZF=1 or SF <> OF
- ....................................................................
-
-
-